var t = require("../../../@babel/runtime/helpers/interopRequireDefault"),
  a = require("../../../@babel/runtime/helpers/defineProperty"),
  e = t(require("../../../@babel/runtime/regenerator")),
  o = require("../../../@babel/runtime/helpers/asyncToGenerator"),
  s = [],
  i = "",
  r = 1,
  d = 0,
  n = 0,
  c = [],
  g = [],
  l = "",
  h = "",
  u = 600;

try {
  var _ = wx.getSystemInfoSync();
  u = _.windowHeight;
} catch (t) {}

var p = getApp();

Page({
  data: {
    showLength: 0,
    language: "",
    store_id: "",
    order_id: "",
    goodsCarts: {},
    showStoreInfo: !1,
    new_comment: {},
    store: {
      comment: {
        average_score: 0,
        comment_total: 0,
        new_comment: null
      },
      goods_total: 0,
      order_count: 0,
      business_hours: "9:00-22:00",
      store_address: "",
      store_mobile: "",
      operating_state: 0
    },
    show1: !1,
    carts: [],
    cartsNum: 0,
    cartsTotal: 0,
    popNum: "",
    title: "",
    path: "",
    activeName: [],
    secondaryId: "",
    category_id: "",
    isBottom: !1,
    category_loading: !1,
    category_last_loading: !1,
    category: [],
    secondCategory: [],
    goodsList: [],
    currentCategory: "",
    goodsCount: 0,
    pageCount: 1,
    specid: "",
    catesId: "",
    loading: !1,
    allLoaded: !0,
    showGoods: !0,
    goodsInfo: {},
    showCart: !1,
    popTitle: "",
    popThumb: "",
    popStock: "",
    popCard: {},
    popPrice: "",
    popmPrice: "",
    goodsDescription: "",
    secondTitle: [],
    goods: [],
    Index: 0,
    showDis: !0,
    scrollTop: 0,
    goodsCartsOld: "",
    tabIndex: 0,
    tab: ["商品", "评价", "商家"],
    info: "",
    toolbar: !1,
    cartchecked: !0,
    goodsBoxheight: "564rpx",
    storeInfoboxtop: 0,
    minicartStyle: "",
    leftPrice: "",
    buttondisab: !0,
    isLoadMore: !0,
    page: 1,
    total_page: 0,
    amout: !1,
    get_coupon: [],
    micro_communities: [],
    get_recommend_goods: [],
    store_member: [],
    store_room: [],
    delivery_note: "",
    delivery_area: [
      [116.403322, 39.920255]
    ],
    locations: [116.403322, 39.920255],
    delivery_status: 0,
    markers_2: [{
      latitude: 23.099994,
      longitude: 113.32452,
      iconPath: "https://webapi.amap.com/theme/v1.3/markers/n/mark_b.png",
      width: 20,
      height: 25,
      callout: {
        padding: "10rpx",
        borderRadius: "5rpx"
      }
    }],
    polygons_2: [{
      points: [],
      fillColor: "#FF88887F",
      strokeColor: "#FFF",
      strokeWidth: 2,
      zIndex: 1
    }],
    delivery: {
      longitude: "113.324520",
      latitude: "23.099994"
    },
    isAeadyLoad: !1,
    get_store_full_package: "",
    get_store_full_reduction: [],
    goodPage: 1,
    goodIsLoadMore: !0,
    goodTotal_page: 0,
    flxShow: !1,
    delivery_amount: 0,
    storeAlone: !1,
    tabIndex2: 0,
    tabList: [],
    menuList: [],
    tabName: 10,
    isLoading: !1,
    is_open: 0,
    balanceTitle: "",
    member_balance: "",
    show_button: 0,
    show_qr_code: !1,
    codeShow: !1,
    acp: !1,
    page: 1
  },
  onLoad: function (t) {
    if (this.initData(), 1 == p.globalData.store_alone_temp && this.setData({
        storeAlone: !0
      }), t.scene) {
      var a = decodeURIComponent(t.scene);
      if (a) {
        var e = [];
        e = a.split(",");
        for (var o = 0; o < e.length; o++) {
          var s;
          s = e[o].split("="), console.log(s), "store_id" == s[0] && this.setData({
            store_id: s[1]
          }), "mid" == s[0] && p._setMid(s[1]), "acp" == s[0] && this.setData({
            acp: !0
          });
        }
      }
    }
    t.store_id && this.setData({
      store_id: t.store_id
    }), 1 == t.fromOrder && this.setData({
      store_id: "",
      order_id: t.store_id
    }), t.mid && p._setMid(t.mid), "comment" === t.activeType && this.setData({
      tabIndex: 1
    }), this.getStoresDetails(), this.data.isAeadyLoad = !0;
    this.getAllGoods()
  },
  address_codeMethod: function () {
    var t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : wx.getStorageSync("yz_basic_info"),
      a = t;
    a.plugin_setting.address_code && a.plugin_setting.address_code.enable && this.addressPopup();
  },
  closeChild: function () {
    this.setData({
      codeShow: !1
    });
  },
  onClickLeft: function () {
    this.setData({
      codeShow: !1
    });
  },
  addressPopup: function () {
    var t = this;
    this.setData({
      codeShow: !0
    }), setTimeout(o(e.default.mark(function a() {
      var o, s;
      return e.default.wrap(function (a) {
        for (;;) switch (a.prev = a.next) {
          case 0:
            return o = t.selectComponent("#yz_showAddress"), a.next = 3, o.getDefaultAddress();

          case 3:
            (s = a.sent) && (o.code_editAddress(s), o.getIsOpenAddress());

          case 5:
          case "end":
            return a.stop();
        }
      }, a);
    })), 1e3);
  },
  toStoreBalance: function (t) {
    "balance" == t.currentTarget.dataset.key ? wx.navigateTo({
      url: "/packageI/independenceBalance/storeBalance/balance_recharge?store_id=" + this.data.store_id
    }) : wx.navigateTo({
      url: "/packageI/independenceBalance/independenceBalance?store_id=" + this.data.store_id
    });
  },
  readImg: function (t) {
    console.log(t);
    var a = t.currentTarget.dataset.url;
    wx.previewImage({
      current: a,
      urls: [a]
    });
  },
  gotoGoodDetail: function (t) {
    
    var a = t.currentTarget.dataset.id;
    wx.navigateTo({
      url: "/packageA/detail_v2/detail_v2?id=" + a
    });
  },
  copybtn: function (t) {
    var a = t.currentTarget.dataset.wechat;
    wx.setClipboardData({
      data: a || "",
      success: function (t) {
        wx.showToast({
          icon: "none",
          title: "复制成功",
          duration: 1e3
        });
      }
    });
  },
  chooseTab: function (t) {
    var a = t.currentTarget.dataset.item;
    this.setData({
      tabIndex2: Number(t.currentTarget.dataset.index),
      tabName: a.value
    }), 50 != this.data.tabIndex ? 80 != a.name ? this.getTabsData() : wx.navigateTo({
      url: "/packageF/storeSign/storeSign/storeSign?id=" + this.data.store_id
    }) : wx.navigateTo({
      url: "/packageD/ActivityDetail/ActivityDetail?id=" + a.id + "&store_id=" + this.data.store_id
    });
  },
  getTabsData: function () {
    var t = this;
    if (this.data.menuList[this.data.tabIndex2].url)
      if (this.data.menuList[this.data.tabIndex2].list.length > 0) this.data.isLoadMore = this.data.menuList[this.data.tabIndex2].isLoadMore;
      else {
        var e = 1,
          o = [];
        this.data.isLoading = !0;
        var s = p.getNetAddresss(this.data.menuList[this.data.tabIndex2].url);
        p._postNetWork({
          url: s,
          data: {
            page: 1,
            store_id: this.data.store_id
          },
          success: function (s) {
            var i, r = s.data;
            1 == r.result ? (20 == t.data.tabName ? (e = r.data.last_page, o = t.setCommunities(r.data.data)) : 40 == t.data.tabName ? o = r.data : null !== (i = r.data) && void 0 !== i && i.data ? (e = r.data.last_page,
                o = r.data.data) : console.log("getTabsData()::error", r.data), t.data.isLoadMore = !0,
              t.data.menuList[t.data.tabIndex2].isLoadMore = !0, t.data.menuList[t.data.tabIndex2].total_page = e,
              t.data.menuList[t.data.tabIndex2].total_page || (t.data.menuList[t.data.tabIndex2].total_page = 0),
              t.setData(a({}, "menuList[" + t.data.tabIndex2 + "].list", o))) : wx.showToast({
              icon: "none",
              title: r.msg,
              duration: 1e3
            });
          },
          fail: function (t) {
            console.log(t);
          }
        });
      }
    else console.log("menu_list该标签没有返回请求api");
  },
  setCommunities: function (t) {
    var a = [];
    return t.map(function (t) {
      a.push({
        id: t.id,
        title: t.title,
        praise_num: t.praise_num,
        has_one_stick_user: {
          avatar: t.user_avatar,
          nickname: t.user_nickname
        },
        has_many_image: [{
          url: t.image,
          stick_id: t.id
        }]
      });
    }), a;
  },
  toCard: function (t) {
    var a = t.currentTarget.dataset.cardid;
    a && wx.navigateTo({
      url: "/packageB/member/business_card/BusinessCard/BusinessCard?card_id=" + a + "&mark=card"
    });
  },
  gomenphone: function (t) {
    var a = t.currentTarget.dataset.phone;
    wx.makePhoneCall({
      phoneNumber: a
    });
  },
  toGood: function (t) {
    var a = t.currentTarget.dataset.id;
    wx.navigateTo({
      url: "/packageA/detail_v2/detail_v2?id=" + a
    });
  },
  onReady: function () {
    var t = wx.getStorageSync("langIndex");
    this.setData({
      language: t.en
    });
  },
  onShow: function () {
    this.data.isAeadyLoad || this.getStoresDetails("cart");
  },
  onHide: function () {
    this.data.isAeadyLoad = !1;
  },
  onUnload: function () {},
  onPullDownRefresh: function () {},
  onReachBottom: function () {
    this.data.isLoadMore ? this._getMoreData() : console.log("没有更多数据");
  },
  _getMoreData: function () {
    var t = this,
      e = this;
    if (this.data.menuList[this.data.tabIndex2].isLoadMore = !1, this.data.isLoadMore = !1,
      !(this.data.menuList[this.data.tabIndex2].page >= this.data.menuList[this.data.tabIndex2].total_page)) {
      var o = [],
        s = {
          store_id: this.data.store_id
        };
      this.data.menuList[this.data.tabIndex2].page = this.data.menuList[this.data.tabIndex2].page + 1,
        s.page = this.data.menuList[this.data.tabIndex2].page;
      var i = p.getNetAddresss(this.data.menuList[this.data.tabIndex2].url);
      p._postNetWork({
        url: i,
        showToastIn: !1,
        data: s,
        success: function (s) {
          var i = s.data;
          if (1 != i.result) return t.data.menuList[t.data.tabIndex2].page = t.data.menuList[t.data.tabIndex2].page - 1,
            t.data.menuList[t.data.tabIndex2].isLoadMore = !1, void(t.data.isLoadMore = !1);
          e.data.isLoadMore = !0, 20 == t.tabName ? o = t.setCommunities(i.data) : 40 == t.tabName ? o = i : i && i.data ? o = i.data : console.log("getTabsData()::error", i),
            t.setData(a({}, "menuList[" + t.data.tabIndex2 + "].list", t.data.menuList[t.data.tabIndex2].list.concat(o)));
        },
        fail: function (t) {
          console.log(t.msg);
        }
      });
    }
  },
  onShareTimeline: function () {
    var t = wx.getStorageSync("yz_uid");
    return {
      title: p._isTextEmpty(this.data.store.store_name) ? "" : this.data.store.store_name,
      path: "/packageC/o2o/o2oStore/o2oStore?fromHome=1&mid=" + t + "&store_id=" + this.data.store_id
    };
  },
  onShareAppMessage: function (t) {
    var a = wx.getStorageSync("yz_uid");
    return {
      title: p._isTextEmpty(this.data.store.store_name) ? "" : this.data.store.store_name,
      path: "/packageC/o2o/o2oStore/o2oStore?fromHome=1&mid=" + a + "&store_id=" + this.data.store_id
    };
  },
  trggleCart: function () {
    0 !== this.data.carts.length && (this.setData({
      showCart: !this.data.showCart
    }), this.getminicartStyle());
  },
  show1Closebtn: function () {
    this.setData({
      show1: !1
    });
  },
  initData: function () {
    this.setData({
      tabIndex: 0,
      category: [],
      goodsList: [],
      currentCategory: "",
      goodsCount: 0,
      pageCount: 1,
      cartsNum: 0,
      cartsTotal: 0,
      carts: [],
      goodsCarts: {},
      specid: ""
    }), s = [], i = "", r = 1, d = 0, n = 0, c = [], g = [], l = "", h = "";
  },
  childShowRead: function () {
    this.data.acp && this.address_codeMethod();
  },
  getStoresDetails: function (t) {
    var a = this,
      e = this,
      o = p.getNetAddresss("plugin.store-cashier.frontend.store.get-store-info.get-stores-details");
    p._postNetWork({
      url: o,
      data: {
        store_id: e.data.store_id,
        order_id: e.data.order_id
      },
      success: function (o) {
        var s = o.data;
        if ("该商家已过期,去看看其他的吧" !== s.msg)
          if (1 == s.result) {
            if (s.data.store_information = s.data.store_information.replace(/<img/gi, '<img style="max-width:100%;height:auto;display:block"'),
              e.setData({
                store: s.data.store_info,
                store_id: s.data.store_info.store_id,
                new_comment: s.data.comment && s.data.comment.new_comment ? s.data.comment.new_comment : {},
                info: s.data.store_information ? s.data.store_information : "",
                infoShow: !!s.data.store_information,
                get_store_full_package: s.data.get_store_full_package,
                get_store_full_reduction: s.data.get_store_full_reduction
              }), e.data.store.store_delivery && 1 == e.data.store.store_delivery.delivery_status) {
              e.setData({
                delivery_status: 1,
                delivery_note: e.data.store.store_delivery ? e.data.store.store_delivery.delivery_note : "",
                delivery_amount: e.data.store.store_delivery ? e.data.store.store_delivery.delivery_amount : 0
              });
              var i = e.data.store.store_delivery && e.data.store.store_delivery.delivery_area ? e.data.store.store_delivery.delivery_area : [],
                r = e.data.store.store_delivery ? e.data.store.store_delivery.locations : [],
                d = [];
              if (i.forEach(function (t, a) {
                  d.push([Number(t.R), Number(t.Q)]);
                }), e.setData({
                  delivery_area: d,
                  locations: [Number(r.longitude).toFixed(6), Number(r.latitude).toFixed(6)]
                }), e.data.locations && e.data.locations.length > 0 && e.setData({
                  "markers_2[0].longitude": e.data.locations[0],
                  "markers_2[0].latitude": e.data.locations[1],
                  "delivery.longitude": e.data.locations[0],
                  "delivery.latitude": e.data.locations[1]
                }), e.data.delivery_area && e.data.delivery_area.length > 0) {
                for (var n = [], c = 0; c < e.data.delivery_area.length; c++) n.push({
                  longitude: e.data.delivery_area[c][0],
                  latitude: e.data.delivery_area[c][1]
                });
                e.setData({
                  "polygons_2[0].points": n
                });
              }
            }
            if (1 === e.data.store.operating_state && e.setData({
                show1: !0
              }), e.setData({
                get_coupon: s.data.get_coupon,
                get_recommend_goods: s.data.get_recommend_goods
              }), s.data.store_balance && 1 == s.data.store_balance.is_open) {
              var g = s.data.store_balance;
              e.setData({
                is_open: g.is_open,
                title: g.title,
                member_balance: g.member_balance,
                show_button: g.show_button,
                show_qr_code: g.show_qr_code
              });
            }
            var l = [],
              h = [];
            s.data.menu_list.forEach(function (t, a) {
              t.is_show && (h.push(t), l.push({
                isLoadMore: !0,
                page: 1,
                total_page: 0,
                list: [],
                url: t.api
              }));
            }), a.setData({
              menuList: l,
              tabList: h,
              tabName: 10,
              tabIndex2: 0
            }), "cart" === t || e.getAllCategory(s.data.first_category), e.getFirstCart(s.data.member_cart);
          } else wx.showToast({
            icon: "none",
            title: s.msg,
            duration: 1500
          });
        else e.setData({
          showDis: !1,
          show8: !0
        });
      },
      fail: function (t) {
        console.log(t);
      }
    });
  },
  onChange: function (t) {
    this.setData({
      activeName: t.detail
    });
  },
  upper: function (t) {
    this.setData({
      amout: !1,
      flxShow: !1
    });
  },
  binddragend: function () {
    if (this.data.isBottom && this.data.goodPage >= this.data.goodTotal_page && !this.data.category_loading) {
      for (var t = "", a = 0; a < this.data.category.length; a++)
        if (this.data.category_id == this.data.category[a].id && this.data.category[a + 1]) {
          t = this.data.category[a + 1].id;
          break;
        }
      // t && (this.setData({
      //   category_id: t
      // }), this.getSecondCategory("load", {
      //   id: this.data.category_id
      // }));
      t && (this.setData({
        category_id: t
      }));
    }
  },
  bindscrolltolower: function () {
    this.data.goodIsLoadMore && this.getMoreGood(), this.data.goodPage >= this.data.goodTotal_page && !this.data.category_loading && (this.data.isBottom = !0);
  },
  bindrefresherpulling: function () {
    // console.log('bindrefresherpulling')
    this.data.isBottom = !1;
  },
  bindrefresherrefresh: function () {
    console.log('bindrefresherrefresh')
    this.getAllGoods()
    // if (this.setData({
    //     category_last_loading: !0
    //   }), this.data.category_last_loading && !this.data.category_loading) {
    //   for (var t = "", a = 0; a < this.data.category.length; a++)
    //     if (this.data.category_id == this.data.category[a].id && this.data.category[a - 1]) {
    //       t = this.data.category[a - 1].id;
    //       break;
    //     }
    //   t ? (console.log("加载上一个一级分类"), this.setData({
    //     category_id: t
    //   }), this.getSecondCategory("load", {
    //     id: this.data.category_id
    //   })) : this.setData({
    //     category_last_loading: !1
    //   });
    // }
    
  },
  foodsScrollbtn: function (t) {
    var a = this,
      e = t.detail.scrollTop;
    n = Math.abs(Math.round(e)), this.data.scrollTop = t.detail.scrollTop, u <= 670 && (t.detail.scrollTop > 10 ? this.data.flxShow || this.setData({
      amout: !0,
      flxShow: !0
    }) : this.data.flxShow && this.setData({
      amout: !1,
      flxShow: !1
    })), setTimeout(function () {
      a.data.isBottom && a.binddragend();
    }, 1e3);
  },
  getAllGoods: function () {
    var i = p.getNetAddresss("HuanNiu.store_goods_ziji");
    var _this = this;
    p._getNetWork({
      url: i,
      data: {
        store_id: _this.data.store_id,
        page: 1,
        text: ''
      },
      success: function (t) {
        console.log(t, 'kskskssksksk')
        var a = t.data;
        if (1 == a.result) {
          console.log(t.data.data.data)
          _this.setData({
            goods: t.data.data.data,
            goodPage: 1,
            goodIsLoadMore: !0,
            goodTotal_page: t.data.data.last_page,
            category_last_loading: !1
          })
        }
      }
    })

  },
  getAllCategory: function (t) {
    var a = this;
    t.second_category.unshift({
      name: "全部",
      id: ""
    }), a.setData({
      category: t.first_category || [],
      secondCategory: t.second_category,
      secondaryId: "",
      // goods: t.goods.data || [],
      goodTotal_page: t.goods.last_page
    }), this.setData({
      showLength: Number(5 - this.data.goods.length) > 0 ? Number(5 - this.data.goods.length) : 1
    }), this.data.category && this.data.category.length > 0 && a.setData({
      category_id: this.data.category[0].id
    });
    var e = wx.createSelectorQuery();
    e.select("#storeInfo_box").boundingClientRect(), e.exec(function (t) {
      a.setData({
        Height: t[0].height + t[0].top - 60
      });
    }), this.getgoodsboxheight();
  },
  getSecondCategory: function (t, a) {
    console.log('下拉刷新')
    var e = this,
      o = {};
    o = "load" == t ? a : t.target.dataset.item || t.currentTarget.dataset.item, this.setData({
      category_id: o.id,
      goods: [],
      amout: !1,
      flxShow: !1,
      category_loading: !0,
      scrollTop: "0"
    }), this.data.isBottom = !1;
    var s = this,
      i = p.getNetAddresss("plugin.store-cashier.frontend.store.get-store-info.get-second-category");
    i += "&store_id=" + this.data.store_id, i += "&category_id=" + this.data.category_id,
      p._getNetWork({
        url: i,
        success: function (t) {
          var a = t.data;
          1 == a.result ? (a.data.second_category.unshift({
            name: "全部",
            id: ""
          }), s.setData({
            category_last_loading: !1,
            secondCategory: a.data.second_category,
            secondaryId: "",
            goods: a.data.goods.data,
            // goodPage: 1,
            // goodIsLoadMore: !0,
            // goodTotal_page: a.data.goods.last_page
          }), e.setData({
            showLength: Number(5 - e.data.goods.length) > 0 ? Number(5 - e.data.goods.length) : 1
          })) : wx.showToast({
            title: a.msg,
            icon: "none",
            duration: 1500
          }), setTimeout(function () {
            e.setData({
              category_last_loading: !1,
              category_loading: !1
            });
          }, 1500);
        },
        fail: function (t) {
          console.log(t);
        }
      });
  },
  getSecondGoods: function (t) {
    var a = this,
      e = t.target.dataset.item || t.currentTarget.dataset.item;
    this.setData({
      secondaryId: e.id,
      activeName: []
    });
    var o = this,
      s = p.getNetAddresss("plugin.store-cashier.frontend.store.get-store-info.get-goods");
    s += "&store_id=" + this.data.store_id, s += "&category_id=" + this.data.category_id,
      s += "&second_category_id=" + this.data.secondaryId, p._getNetWork({
        url: s,
        success: function (t) {
          var e = t.data;
          1 == e.result ? (o.setData({
            goods: e.data.goods.data,
            goodPage: 1,
            goodIsLoadMore: !0,
            goodTotal_page: e.data.goods.last_page
          }), a.setData({
            showLength: Number(5 - a.data.goods.length) > 0 ? Number(5 - a.data.goods.length) : 1
          })) : wx.showToast({
            title: e.msg,
            icon: "none",
            duration: 1500
          });
        },
        fail: function (t) {
          console.log(t);
        }
      });
  },
  getMoreGood: function () {
    var t = this,
      a = this;
    console.log('走了么',this.data.goodPage,this.data.goodTotal_page)
    if (this.setData({
        goodIsLoadMore: !1,
        category_loading: !0
    }), this.data.goodPage >= this.data.goodTotal_page) console.log("没有更多了"), this.setData({
        category_loading: !1
    }); else {
        console.log("加载更多"), this.setData({
            goodPage: this.data.goodPage + 1
        });
        var e = p.getNetAddresss("HuanNiu.store_goods_ziji");
        e += "&store_id=" + this.data.store_id, e += "&page=" + this.data.goodPage, 
        p._getNetWork({
            url: e,
            success: function(e) {
                var o = e.data;
                console.log(o,'ksksksksksk')
                1 == o.result ? (a.setData({
                    goodIsLoadMore: !0,
                    goods: t.data.goods.concat(o.data.data)
                }), t.data.goodPage >= t.data.goodTotal_page && a.setData({
                    goodIsLoadMore: !1
                })) : (a.setData({
                    goodIsLoadMore: !1,
                    goodPage: t.goodPage - 1
                }), wx.showToast({
                    title: o.msg,
                    icon: "none",
                    duration: 1500
                })), a.setData({
                    category_loading: !1
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    }
  },
  // getMoreGood: function() {
  //     var t = this, a = this;
  //     if (this.setData({
  //         goodIsLoadMore: !1,
  //         category_loading: !0
  //     }), this.data.goodPage >= this.data.goodTotal_page) console.log("没有更多了"), this.setData({
  //         category_loading: !1
  //     }); else {
  //         console.log("加载更多"), this.setData({
  //             goodPage: this.data.goodPage + 1
  //         });
  //         var e = p.getNetAddresss("plugin.store-cashier.frontend.store.get-store-info.get-goods");
  //         e += "&store_id=" + this.data.store_id, e += "&category_id=" + this.data.category_id, 
  //         e += "&second_category_id=" + this.data.secondaryId || 0, e += "&page=" + this.data.goodPage, 
  //         p._getNetWork({
  //             url: e,
  //             success: function(e) {
  //                 var o = e.data;
  //                 1 == o.result ? (a.setData({
  //                     goodIsLoadMore: !0,
  //                     goods: t.data.goods.concat(o.data.goods.data)
  //                 }), t.data.goodPage >= t.data.goodTotal_page && a.setData({
  //                     goodIsLoadMore: !1
  //                 })) : (a.setData({
  //                     goodIsLoadMore: !1,
  //                     goodPage: t.goodPage - 1
  //                 }), wx.showToast({
  //                     title: o.msg,
  //                     icon: "none",
  //                     duration: 1500
  //                 })), a.setData({
  //                     category_loading: !1
  //                 });
  //             },
  //             fail: function(t) {
  //                 console.log(t);
  //             }
  //         });
  //     }
  // },
  gopage: function (t) {
    var a = t.currentTarget.dataset.status,
      e = t.currentTarget.dataset.id,
      o = t.currentTarget.dataset.backid;
    1 == a ? wx.navigateTo({
      url: "/packageD/directSeeding/livePage/livePage?id=" + e + "&playerType=live"
    }) : 2 == a ? wx.navigateTo({
      url: "/packageD/directSeeding/livePage/livePage?id=" + e + "&playerType=video&backid=" + o
    }) : 3 == a && wx.navigateTo({
      url: "/packageD/directSeeding/foreshow/foreshow?id=" + e
    });
  },
  getCategory: function (t) {
    var e = this,
      o = this;
    if (this.setData({
        category: t.list || []
      }), this.data.category.length > 0)
      for (var s = function (t) {
          if (e.data.category[t].childrens.length > 0) {
            if (e.setData(a({}, "category[" + t + "].active", !0)), e.data.category[t].childrens.length > 0) {
              var s;
              e.setData((a(s = {}, "category[" + t + "].childrens[0].active", !0), a(s, "currentCategory", e.data.category[t].childrens[0].name),
                a(s, "catesId", e.data.category[t].childrens[0].id), s));
              var i = [],
                r = [];
              e.data.category.forEach(function (a, e) {
                console.log(a), a.childrens.length > 0 ? (1 == a.childrens.length || a.childrens && a.childrens[t].goods.length >= 0) && i.push(a.childrens) : i.push([]);
              }), i.forEach(function (t) {
                t.length > 0 && t.forEach(function (t) {
                  r.push({
                    id: t.id,
                    name: t.name
                  });
                });
              }), e.setData({
                secondTitle: r,
                goods: i
              }), e.setData({
                showLength: Number(5 - e.data.goods.length) > 0 ? Number(5 - e.data.goods.length) : 1
              });
              var d = wx.createSelectorQuery();
              d.select("#storeInfo_box").boundingClientRect(), d.exec(function (t) {
                  o.setData({
                    Height: t[0].height + t[0].top - 60
                  });
                }), e.getgoodsboxheight(), e._calculateCategoryHeight(), e._calculateHeight(), e.currentCategoryIndexBtn(),
                e.currentIndexBtn(), e.setData({
                  currentCategoryIndex: t
                });
            }
            return "break";
          }
        }, i = 0; i < this.data.category.length; i++) {
        if ("break" === s(i)) break;
      }
  },
  getgoodsboxheight: function () {
    var t = this,
      a = wx.createSelectorQuery();
    a.select("#nav").boundingClientRect();
    var e = wx.createSelectorQuery();
    e.select("#settlecomplete").boundingClientRect();
    var o = wx.createSelectorQuery();
    o.select("#search_top").boundingClientRect(), a.exec(function (a) {
      e.exec(function (e) {
        o.exec(function (o) {
          t.setData({
            goodsBoxheight: u <= 670 ? u - e[0].height - o[0].height - (a[0].top + a[0].height) + t.data.Height + "px" : u - e[0].height - o[0].height - t.data.Height + "px"
          });
        });
      });
    });
  },
  _calculateCategoryHeight: function () {
    var t = 0;
    g.push(t);
    var a = wx.createSelectorQuery();
    a.selectAll("#foodsWrapper .food-list").boundingClientRect(), a.exec(function (a) {
      for (var e = a[0], o = 0; o < e.length; o++) {
        var s = e[o];
        t += s.height, g.push(t);
      }
    });
  },
  _calculateHeight: function () {
    var t = 0;
    c.push(t);
    var a = wx.createSelectorQuery();
    a.selectAll("#foodsWrapper .food-list-hook").boundingClientRect(), a.exec(function (a) {
      for (var e = a[0], o = 0; o < e.length; o++) {
        var s = e[o];
        t += s.height, c.push(t);
      }
    });
  },
  currentCategoryIndexBtn: function () {
    for (var t = 0; t < g.length; t++) {
      var a = g[t],
        e = g[t + 1];
      if (null == e || n >= a && n < e) return l !== a && this.setData({
        currentCategoryIndex: t
      }), l = a, !1;
    }
    this.setData({
      currentCategoryIndex: 0
    });
  },
  currentIndexBtn: function () {
    for (var t = 0; t < c.length; t++) {
      var a = c[t],
        e = c[t + 1];
      if (!e || n >= a && n < e) return h !== a && this.setData({
        currentIndex: this.data.secondTitle[t].id
      }), h = a, !1;
    }
    this.setData({
      currentIndex: 0
    });
  },
  getFirstCart: function (t) {
    var a = this;
    this.setData({
      carts: t,
      goodsCarts: [],
      cartsNum: 0,
      cartsTotal: 0
    });
    var e = {};
    this.data.carts.forEach(function (t) {
      e[t.goods_id] = t, t.goods_id === a.data.goodsInfo.id && t.option_id === i && a.setData({
        popNum: t.total,
        popCard: t
      }), a.setData({
        cartsNum: a.data.cartsNum + t.total,
        cartsTotal: a.data.cartsTotal + t.total * t.goods.price
      });
    }), this.setData({
      goodsCarts: e,
      goodsCartsTotal: this.calculateTotal(this.data.carts),
      cartsTotal: parseFloat(this.data.cartsTotal).toFixed(2)
    });
  },
  searchJump: function () {
    wx.navigateTo({
      url: "/packageC/o2o/StoreSearch/StoreSearch?store_id=" + this.data.store_id + "&fromHome=1"
    });
  },
  gotoCupcon: function () {
    wx.navigateTo({
      url: "/packageC/o2o/store_coupon/store_coupon?id=" + this.data.store_id
    });
  },
  changeTab: function (t) {
    var a = t.currentTarget.dataset.index;
    this.setData({
      tabIndex: a
    }), this.setData({
      amout: !1,
      flxShow: !1
    });
  },
  goBuy: function () {
    wx.navigateTo({
      url: "/packageC/cashier/cashier_pay/cashier_pay?store_id=" + this.data.store_id
    });
  },
  selectCategoryMenu: function (t) {
    var a = t.currentTarget.dataset.items;
    a.childrens[0] ? (this.selectMenu(a.childrens[0].id), console.log("kkk", a)) : wx.showToast({
      icon: "none",
      title: "该分类暂无商品",
      duration: 1500
    });
  },
  selectMenuBtn: function (t) {
    var a = t.currentTarget.dataset.id;
    this.selectMenu(a);
  },
  goToGoodsO2O: function (t) {
    console.log(t,'goToGoodsO2O')
    var a = t.currentTarget.dataset.food;
    1 !== this.data.store.operating_state && wx.navigateTo({
      // url: "/packageA/detail_v2/detail_v2?id=" + a.goods_id + "&tag=o2o&store_id=" + this.data.store_id
      url: "/packageA/detail_v2/detail_v2?id=" + a.id + "&tag=o2o&store_id=" + this.data.store_id
    });
  },
  addGood: function (t) {
    var a = t.currentTarget.dataset.item;
    if (a.vip_level_status && 1 == a.vip_level_status.status) return wx.showToast({
      title: a.vip_level_status.tips,
      icon: "none",
      duration: 2e3
    }), !1;
    this.setData({
      show2: !0,
      goodsInfo: a
    }), this.initPopView();
  },
  numberLeft: function (t) {
    if (this.data.buttondisab) {
      wx.showLoading({
        title: "添加商品中"
      }), this.setData({
        buttondisab: !1
      });
      var a = t.currentTarget.dataset.food,
        e = t.currentTarget.dataset.goods;
      p._isTextEmpty(e) ? this.updateCart(e.id, -1) : (this.setData({
        goodsCartsOld: e.total
      }), d = 0, this.updateCart(this.data.goodsCarts[a.id].id, -1));
    }
  },
  numberLeft1: function (t) {
    if (this.data.buttondisab) {
      wx.showLoading({
        title: "添加商品中"
      }), this.setData({
        buttondisab: !1
      });
      var e = t.currentTarget.dataset.item,
        o = t.currentTarget.dataset.index;
      p._isTextEmpty(e) ? this.updateCart(e.id, -1) : (this.setData(a({
        goodsCartsOld: e.total
      }, "carts[" + o + "].total", Number(e.total) - 1)), d = 0, this.updateCart(this.data.carts[o].id, -1));
    }
  },
  numberRight: function (t) {
    if (this.data.buttondisab) {
      wx.showLoading({
        title: "添加商品中"
      }), this.setData({
        buttondisab: !1
      });
      var e = t.currentTarget.dataset.food,
        o = t.currentTarget.dataset.goods;
      if (e.vip_level_status && 1 == e.vip_level_status.status) return wx.showToast({
        title: e.vip_level_status.tips,
        icon: "none",
        duration: 2e3
      }), !1;
      console.log("cc1:::", e), console.log("cc2:::", o);
      var s = t.currentTarget.dataset.goodindex,
        i = t.currentTarget.dataset.index,
        r = t.currentTarget.dataset.foodindex;
      p._isTextEmpty(o) || this.setData(a({
          goodsCartsOld: o.total
        }, "goodsCarts[" + e.id + "].total", Number(this.data.goodsCarts[e.id].total) + 1)),
        this.addCart(e, "", s, i, r);
    }
  },
  numberRight1: function (t) {
    if (this.data.buttondisab) {
      this.setData({
        buttondisab: !1
      }), wx.showLoading({
        title: "添加商品中"
      });
      var e = t.currentTarget.dataset.item,
        o = t.currentTarget.dataset.index;
      p._isTextEmpty(e) || this.setData(a({
        goodsCartsOld: e.total
      }, "carts[" + o + "].total", Number(e.total) + 1)), this.addCart(e, "cart");
    }
  },
  changeCount_2: function (t) {
    var a = t.detail.value,
      e = t.currentTarget.dataset.index;
    this.data.goodsCarts[id].total = a, this.setData({
      goodsCarts: this.data.goodsCarts
    });
    var o = this.data.carts[e];
    if (o.total < 0) return wx.showToast({
      icon: "none",
      title: "商品数量不能为负数",
      duration: 1500
    }), this.data.goodsCarts[id].total = this.data.goodsCartsOld, void this.setData({
      goodsCarts: this.data.goodsCarts
    });
    if (o.total < this.data.goodsCartsOld) {
      var s = this.data.goodsCartsOld - o.total;
      this.updateCart(o.id, -s);
    } else if (o.total > this.data.goodsCartsOld) {
      var i = o.total - this.data.goodsCartsOld;
      this.updateCart(o.id, i);
    }
  },
  updateCartBtn: function (t) {
    var a = t.currentTarget.dataset.id,
      e = t.currentTarget.dataset.num;
    this.updateCart(a, e);
  },
  updateCart: function (t, a) {
    if (a < 0) {
      var e = 0;
      if (this.data.carts.forEach(function (a) {
          console.log(a), a.id == t && (e = a.total);
        }), e + a < 0) return void(0 === d && (d = 1, this.delItemByCart(t), setTimeout(function () {
        d = 0;
      }, 500)));
      0 === d && (d = 1, this.updateCartRequest(t, a), setTimeout(function () {
        d = 0;
      }, 500));
    } else 0 === d && (d = 1, this.updateCartRequest(t, a), setTimeout(function () {
      d = 0;
    }, 500));
  },
  delItemByCart: function (t) {
    var a = this,
      e = p.getNetAddresss("plugin.store-cashier.frontend.shoppingCart.member-cart.destroy");
    e += "&store_id=" + this.data.store_id, e += "&ids=" + t, p._getNetWork({
      url: e,
      success: function (t) {
        var e = t.data;
        1 == e.result ? (a.getCart(), a.setData({
          popNum: a.data.popNum - 1,
          showCart: !1
        }), a.getminicartStyle()) : wx.showToast({
          title: e.msg,
          icon: "none",
          duration: 1500
        });
      },
      fail: function (t) {
        console.log(t);
      }
    });
  },
  updateCartRequest: function (t, a) {
    var e = this,
      o = p.getNetAddresss("plugin.store-cashier.frontend.shoppingCart.member-cart.updateNum");
    o += "&id=" + t, o += "&num=" + a, o += "&store_id=" + this.data.store_id, p._getNetWork({
      url: o,
      success: function (t) {
        var o = t.data;
        1 == o.result ? (a < 0 ? e.setData({
          popNum: e.data.popNum - 1
        }) : e.setData({
          popNum: e.data.popNum + 1
        }), e.getCart()) : (wx.showToast({
          title: o.msg,
          icon: "none",
          duration: 1500
        }), e.getCart());
      },
      fail: function (t) {
        console.log(t);
      }
    });
  },
  changeCount_1: function (t) {
    var a = t.detail.value,
      e = t.currentTarget.dataset.id;
    this.data.goodsCarts[e].total = a, this.setData({
      goodsCarts: this.data.goodsCarts
    });
    var o = this.data.goodsCarts[e];
    if (o.total < 0) return wx.showToast({
      icon: "none",
      title: "商品数量不能为负数",
      duration: 1500
    }), this.data.goodsCarts[e].total = this.data.goodsCartsOld, void this.setData({
      goodsCarts: this.data.goodsCarts
    });
    if (o.total < this.data.goodsCartsOld) {
      var s = this.data.goodsCartsOld - o.total;
      this.updateCart(o.id, -s);
    } else if (o.total > this.data.goodsCartsOld) {
      var i = o.total - this.data.goodsCartsOld;
      this.updateCart(o.id, i);
    } else if (o.total == this.data.goodsCartsOld) return;
  },
  clickCount: function (t) {
    var a = t.currentTarget.dataset.total;
    this.setData({
      goodsCartsOld: a
    });
  },
  Countstop: function (t) {},
  addCart: function (t, a, e, o, s) {
    var i = this,
      r = "";
    r = "cart" === a ? t.goods_id : t.id;
    var d = p.getNetAddresss("plugin.store-cashier.frontend.shoppingCart.member-cart.store");
    d += "&goods_id=" + r, d += "&total=1", d += "&store_id=" + this.data.store_id,
      d += "&option_id=" + (t.option_id ? t.option_id : 0), p._getNetWork({
        url: d,
        success: function (t) {
          var a = t.data;
          1 == a.result ? i.getCart() : (i.getCart(), wx.showToast({
            title: a.msg,
            icon: "none",
            duration: 1500
          }));
        },
        fail: function (t) {
          console.log(t);
        }
      });
  },
  getCart: function (t, a, e) {
    var o = this,
      s = p.getNetAddresss("plugin.store-cashier.frontend.shoppingCart.member-cart.index");
    s += "&store_id=" + this.data.store_id, p._getNetWork({
      url: s,
      success: function (t) {
        var a = t.data;
        if (1 == a.result) {
          o.setData({
            carts: a.data,
            goodsCarts: []
          }), o.data.cartsNum = 0, o.data.cartsTotal = 0;
          var e = 0,
            s = 0,
            r = {};
          o.data.carts.forEach(function (t, a) {
            r[t.goods_id] = t, t.goods_id === o.data.goodsInfo.id && t.option_id === i && o.setData({
              popNum: t.total,
              popCard: t
            }), e += t.total, s += t.total * t.goods.price;
          }), o.setData({
            goodsCarts: r,
            cartsNum: e,
            cartsTotal: parseFloat(s).toFixed(2),
            goodsCartsTotal: o.calculateTotal(o.data.carts)
          });
        }
        wx.hideLoading(), o.setData({
          buttondisab: !0
        });
      },
      fail: function (t) {
        wx.hideLoading(), o.setData({
          buttondisab: !0
        }), console.log(t);
      }
    });
  },
  calculateTotal: function (t) {
    var a = [],
      e = {},
      o = {};
    for (var s in t) {
      var i = t[s].goods_id;
      e[i] ? e[i].total = e[i].total + t[s].total : (e[i] = {}, e[i].goods_id = t[s].goods_id,
        e[i].total = t[s].total);
    }
    for (var r in e) a.push(e[r]);
    return a.forEach(function (t) {
      o[t.goods_id] = t;
    }), o;
  },
  selectMenu: function (t) {
    var a = this;
    console.log(t), this.data.secondTitle.forEach(function (e, o) {
      if (e.id === t) return a.setData({
        Index: o,
        scrollTop: c[o]
      }), o;
    });
  },
  goToAdress: function () {
    var t = this.data.store.lat,
      a = this.data.store.lng,
      e = this.data.store.store_name,
      o = p.BMapTransqqMap(parseFloat(a), parseFloat(t));
    wx.openLocation({
      latitude: o.lat,
      longitude: o.lng,
      scale: 18,
      name: e
    });
  },
  gophone: function () {
    var t = this.data.store.store_mobile;
    wx.makePhoneCall({
      phoneNumber: t
    });
  },
  isHasDifferType: function (t) {
    var a = this,
      e = 0,
      o = 0,
      s = "";
    for (var i in t) i.live_install && 1 == i.live_install.open_state ? (e += 1, s = i.live_install.plugin_name) : o += 1;
    return 0 == e || 0 == o || (wx.showModal({
      title: "提示",
      content: "普通商品与".concat(s, "商品一同下单将无法享受").concat(s, "，是否继续下单？"),
      success: function (e) {
        e.confirm ? a._goodsOrder(t, !0) : e.cancel && console.log(e.cancel);
      }
    }), !1);
  },
  goodsOrder: function (t) {
    var a = t.currentTarget.dataset.goodscarts;
    this._goodsOrder(a);
  },
  _goodsOrder: function (t, a) {
    var e = 0;
    (a || this.isHasDifferType(t)) && (this.data.carts.forEach(function (t) {
      e += t.total;
    }), 0 != e && 0 != t.length && 0 != this.data.carts.length && wx.navigateTo({
      url: "/packageD/buy/myOrder_v2/myOrder_v2?tag=store&store_id=" + this.data.store_id + "&goodsType=store_goods"
    }));
  },
  clearCart: function () {
    var t = this,
      a = [];
    this.data.carts.forEach(function (t) {
      a.push(t.id);
    });
    var e = p.getNetAddresss("plugin.store-cashier.frontend.shoppingCart.member-cart.destroy");
    e += "&store_id=" + this.data.store_id, e += "&ids=" + a, p._getNetWork({
      url: e,
      success: function (a) {
        var e = a.data;
        1 == e.result ? (t.getCart(), t.setData({
          showCart: !1,
          popNum: 0
        }), t.getminicartStyle()) : wx.showToast({
          title: e.msg,
          icon: "none",
          duration: 1500
        });
      },
      fail: function (t) {
        console.log(t);
      }
    });
  },
  goTOHome: function () {
    wx.redirectTo({
      url: "/packageC/o2o/o2oHome/o2oHome"
    });
  },
  close: function () {
    this.setData({
      show2: !1
    }), i = "", s = [], this.setData({
      specid: "",
      popNum: 0
    });
  },
  selectSpecs: function (t, a, e) {
    var o = 0,
      s = 0,
      i = 0;
    "first" == a ? (o = t.id, s = 0, i = e) : (o = t.currentTarget.dataset.itemid, s = t.currentTarget.dataset.index,
        i = t.currentTarget.dataset.indexl), this.manageSpecs(i, s), this.setGoodsSpecs(i, s),
      this.setGoodsSpecsChangeInfo(o), this.getMaxCount();
  },
  manageSpecs: function (t, a) {
    var e = this.data.goodsInfo.has_many_specs[t].specitem[a],
      o = new Object();
    if (o.id = e.id, o.specid = e.specid, o.title = e.title, s.length > 0) {
      for (var i = 0; i < s.length; i++) s[i].specid == o.specid && s.splice(i, 1);
      s.push(o);
    } else s.push(o);
    if (s.length == this.data.goodsInfo.has_many_specs.length) {
      for (var r = [], d = 0; d < this.data.goodsInfo.has_many_specs.length; d++)
        for (var n = 0; n < s.length; n++)
          if (this.data.goodsInfo.has_many_specs[d].id == s[n].specid) {
            r.push(s[n]);
            break;
          }
      s = r;
    }
    this.setGoodsDescription();
  },
  setGoodsDescription: function () {
    var t = "";
    if (s.length == this.data.goodsInfo.has_many_specs.length) {
      t = "已选择 ";
      for (var a = 0; a < s.length; a++) t += s[a].title + " ";
      this.setData({
        goodsDescription: t
      });
    } else {
      t = "请选择 ";
      for (var e = 0; e < this.data.goodsInfo.has_many_specs.length; e++)
        for (var o = 0; o < s.length; o++)
          if (this.data.goodsInfo.has_many_specs[e].id != s[o].specid) {
            t += this.data.goodsInfo.has_many_specs[e].title + " ";
            break;
          }
      this.setData({
        goodsDescription: t
      });
    }
  },
  setGoodsSpecs: function (t, a) {
    for (var e = this.data.goodsInfo.has_many_specs[t].specitem[a], o = 0; o < this.data.goodsInfo.has_many_specs.length; o++) e.specid != this.data.goodsInfo.has_many_specs[o].id && this.setGoodsSpecsStatus(o, e.id);
  },
  setGoodsSpecsStatus: function (t, e) {
    for (var o = this.data.goodsInfo.has_many_specs[t].specitem, s = [], i = 0; i < this.data.goodsInfo.has_many_options.length; i++)
      for (var r = this.data.goodsInfo.has_many_options[i].specs.split("_"), d = 0; d < r.length; d++)
        if (r[d] == e) return void s.push(this.data.goodsInfo.has_many_options[i]);
    for (var n = 0; n < s.length; n++)
      for (var c = s[n].specs.split("_"), g = 0; g < c.length; g++)
        if (c[g] != e && 0 == s[n].stock) {
          for (var l = 0; l < o.length; l++)
            if (c[g] == o[l].id) return void this.setData(a({}, "data.goodsInfo.has_many_specs[" + t + "].specitem[" + l + "].c", !0));
        } else if (c[g] != e && s[n].stock > 0)
      for (var h = 0; h < o.length; h++)
        if (c[g] == o[h].id) return void this.setData(a({}, "data.goodsInfo.has_many_specs[" + t + "].specitem[" + h + "].c", !1));
  },
  setGoodsSpecsChangeInfo: function (t) {
    if (s.sort(function (t, a) {
        return t.id - a.id;
      }), s.length === this.data.goodsInfo.has_many_specs.length) {
      for (var a = "", e = 0; e < s.length; e++) a += s[e].id + "_";
      a = a.substring(0, a.length - 1), this.setData({
        specid: a
      });
      for (var o = 0; o < this.data.goodsInfo.has_many_options.length; o++)
        if (a === this.setGoodsSpecsBySort(this.data.goodsInfo.has_many_options[o].specs)) {
          this.setData({
            popmPrice: this.data.goodsInfo.has_many_options[o].market_price,
            popPrice: this.data.goodsInfo.has_many_options[o].product_price,
            popThumb: p._isTextEmpty(this.data.goodsInfo.has_many_options[o].thumb) ? this.data.goodsInfo.thumb : this.data.goodsInfo.has_many_options[o].thumb,
            popStock: this.data.goodsInfo.has_many_options[o].stock
          }), i = this.data.goodsInfo.has_many_options[o].id, (r = this.data.goodsInfo.has_many_options[o].stock) > 0 && this.setData({
            popNum: 0
          });
          break;
        }
      for (var d = 0; d < this.data.carts.length; d++) {
        if (this.data.carts[d].goods_id === this.data.goodsInfo.id && this.data.carts[d].option_id === i) {
          this.setData({
            popNum: this.data.carts[d].total,
            popCard: this.data.carts[d]
          });
          break;
        }
        this.setData({
          popNum: 0,
          popCard: {}
        });
      }
    } else {
      for (var n = "", c = 0; c < s.length; c++) n += s[c].id + "_";
      this.setData({
        specid: n
      });
    }
  },
  setGoodsSpecsBySort: function (t) {
    var a = t.split("_");
    a.sort(function (t, a) {
      return t - a;
    });
    for (var e = "", o = 0; o < a.length; o++) e += a[o] + "_";
    return e = e.substring(0, e.length - 1);
  },
  getMaxCount: function () {
    s.length == this.data.goodsInfo.has_many_specs.length && (0 == r && this.setData({
      popNum: 0
    }), this.data.popNum > r && this.setData({
      popNum: r
    }));
  },
  submitAction: function () {
    if (s.length < this.data.goodsInfo.has_many_specs.length) return this.setData({
      show2: !1
    }), void wx.showToast({
      title: this.data.goodsDescription,
      icon: "none",
      duration: 1500
    });
    this.addCartRequest(this.data.goodsInfo.id, i);
  },
  addCartRequest: function (t, a) {
    if (0 !== r) {
      var e = this,
        o = p.getNetAddresss("plugin.store-cashier.frontend.shoppingCart.member-cart.store");
      o += "&goods_id=" + t, o += "&total=1", o += "&option_id=" + a, o += "&store_id=" + this.data.store_id,
        p._getNetWork({
          url: o,
          success: function (t) {
            var a = t.data;
            1 == a.result ? (e.setData({
              popNum: e.data.popNum + 1
            }), e.getCart(), wx.showToast({
              title: a.msg,
              icon: "none",
              duration: 1500
            })) : wx.showToast({
              title: a.msg,
              icon: "none",
              duration: 1500
            });
          },
          fail: function (t) {
            console.log(t);
          }
        });
    } else wx.showToast({
      title: "商品库存不足",
      icon: "none",
      duration: 1500
    });
  },
  showToolbar: function () {
    this.setData({
      toolbar: !this.data.toolbar
    });
  },
  gohome: function () {
    wx.reLaunch({
      url: "/packageG/index/index"
    });
  },
  goorderlist: function () {
    wx.navigateTo({
      url: "/packageA/member/myOrder_v2/myOrder_v2"
    });
  },
  gomember: function () {
    wx.reLaunch({
      url: "/packageG/member_v2/member_v2"
    });
  },
  cartChange: function (t) {
    var a = t.detail;
    this.setData({
      cartchecked: a
    });
  },
  initPopView: function () {
    if (i = "", s = [], this.setData({
        specid: "",
        popNum: 0
      }), 1 === this.data.goodsInfo.has_option) {
      this.setData({
        popTitle: this.data.goodsInfo.title,
        popThumb: this.data.goodsInfo.thumb,
        popStock: this.data.goodsInfo.stock,
        popCard: {}
      }), this.data.specid.length || this.setData({
        popPrice: this.data.goodsInfo.min_price + "-" + this.data.goodsInfo.max_price
      }), this.setData({
        goodsDescription: "请选择"
      });
      for (var t = 0; t < this.data.goodsInfo.has_many_specs.length; t++) this.setData({
        goodsDescription: this.data.goodsDescription + " " + this.data.goodsInfo.has_many_specs[t].title
      });
      if (!this.data.optionsId)
        for (var a = 0; a < this.data.goodsInfo.has_many_specs.length; a++) this.selectSpecs(this.data.goodsInfo.has_many_specs[a].specitem[0], "first", a);
    } else this.setData({
      goodsDescription: ""
    }), r = this.data.goodsInfo.stock;
  },
  getminicartStyle: function () {
    this.data.showCart ? this.setData({
      minicartStyle: "display: none;transform: translateY(-100%)",
      leftPrice: "transform: translateX(-60px);"
    }) : this.setData({
      minicartStyle: "transform: translateY(0)",
      leftPrice: ""
    });
  }
});